package com.woniuxy.purchase.util;

import lombok.Data;

@Data
public class R<T> {
    /*返回体*/
    private Integer code;
    private String msg;
    private T data;

    public static R success(Object object) {
        R r = new R();
        r.setCode(RCode.SUCCESS.getCode());
        r.setMsg(RCode.SUCCESS.getMsg());
        r.setData(object);
        return r;
    }

    //成功，但返回体没数据
    public static R success() {
        return success(null);
    }

    //失败返回信息
    public static R error(Integer code, String msg) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        return r;
    }
}